package com.zz.parkingsystem.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zz.parkingsystem.dto.PageDTO;
import com.zz.parkingsystem.entity.Admin;
import com.zz.parkingsystem.entity.SystemLogin;
import com.zz.parkingsystem.mapper.SystemLoginMapper;
import com.zz.parkingsystem.service.SystemLoginService;
import com.zz.parkingsystem.vo.PageResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wangyuxiang
 */
@Service
public class SystemLoginServiceImpl implements SystemLoginService {
    @Resource
    private SystemLoginMapper systemLoginMapper;

    /**
     * 插入日志数据
     * @param record
     * @return
     */
    @Override
    public int insertSelective(SystemLogin record) {
        return systemLoginMapper.insertSelective(record);
    }

    @Override
    public PageResult queryAllSystemLogin(PageDTO pageDTO) {
        Integer pageSize = pageDTO.getPageSize();
        Integer pageIndex = pageDTO.getPageIndex();
        PageHelper.startPage(pageIndex,pageSize);
        List<SystemLogin> list = systemLoginMapper.queryAllSystemLogin();
        PageInfo pageInfo = new PageInfo(list);
        PageHelper.clearPage();
        PageResult pageResult = new PageResult();
        pageResult.setPages(pageInfo.getPages());
        pageResult.setTotal((int)pageInfo.getTotal());
        pageResult.setList(list);
        return pageResult;
    }


    @Override
    public int deleteByPrimaryKey(Long id) {
        return systemLoginMapper.deleteByPrimaryKey(id);
    }


}
